package com.gem.talkbase.adapter;

import java.util.List;
import com.gem.talkbase.R;
import com.gem.talkbase.bean.Contacts;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;


public class ContactAddAdapter extends BaseAdapter {
	private List<Contacts> list1;
	private String lxr_name,lxr_tj;
	LayoutInflater inflater;
	private Context context2;
	public ContactAddAdapter(Context context2,List<Contacts> list){
		 this.context2=context2;
		 this.list1=list;
		 inflater = LayoutInflater.from(context2);	 
		  
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
	System.out.println("hjasdashdhashdhashdhashdhsdhashdhhasdhhas========================");//
		final ViewHolder viewHolder;
		if(convertView==null){
		convertView = inflater.inflate(
					R.layout.contacts,null);
		}
		
		viewHolder = new ViewHolder();
		System.out.println(convertView+"=================================jjjjjj");
		viewHolder.lxr_name = (TextView) convertView.findViewById(R.id.name);//名字
		viewHolder.lxr_tj = (TextView) convertView.findViewById(R.id._yaoqin);//时间
		
		System.out.println("shaolei==========================================");

		Contacts entity = list1.get(position);
		lxr_name=entity.getLxr_name();
		lxr_tj=entity.get_tj_lxr();
		
		System.out.println("===============================================");
  
          viewHolder.lxr_name.setText(lxr_tj);
		  viewHolder.lxr_tj.setText(lxr_name);
		  
	  
		return convertView;
		
	}

	private static class ViewHolder {
	  
		TextView lxr_name;//时间
		TextView lxr_tj;//消息

	}

	@Override
	public int getCount() {//getCount()为0则不会执行getView()方法。
		// TODO Auto-generated method stub
			return list1.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list1.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

}
